package assignment1;

/**
 * Create a Server object, specify a port to bind to.
 * Create clients specifying the server address and port to bind to.
 * The client can then sendMessage and receiveMessage.
 */

public class Tester {
	
	public static Server makeServer() {
		int port = 34734;
		Server s = new Server(port);
		return s;
	}
	
	public static Client makeClient() {
		String address = "localhost";
		int port = 34734;
		
		Client c = new Client(address, port);
		return c;
	}
	
	public static void main(String[] args) {
		Server s = makeServer();
		s.start();
		Client c = makeClient();
		
		c.sendMessage("Hey guys", true);
		System.out.println("Message should be received in uppercase");
		System.out.println("In upper case: "+c.readMessage());
		System.out.println();
		
		c.sendMessage("Hello world", false);
		System.out.println("Message should be received in lowercase");
		System.out.println("In lower case: "+c.readMessage());
		
		System.out.println();
		System.out.println("Automatic client testing...");
		ClientTester ct = new ClientTester(c, "Tester");
		ct.run();
		
		c.close();
		s.stop();
	}
}
